<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>论文管理页面</h2>

论文主题：<input type="text"/>论文类型：<form action="http://vip.biancheng.net/login.php" method="post">
 论文类型：
  <select>
    <option>应用型</option>
    <option>18-28岁</option>
    <option>28-38岁</option>
    <option>38岁以上</option>
  </select>
</form>
<input type="button" value="查询">
<a href="/addLunTan">添加论文</a>

<table border="1" id="charu">
    <tr >
        <th>论文主题</th>
        <th>作者</th>
        <th>论文类型</th>
        <th>发表时间</th>
        <th>修改时间</th>
        <th>操作</th>
    </tr>
</table>
<script src="http://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script>
<script>

    $(function (){
        $.ajax({
            "url": '/lunWenList',
            "type": "post",
            "dataType": "json",
            "success": function (a) {

                for(var i = 0 ; i < a.length ; i++){
                    console.log(a);
                    var html = " <tr>\n" +
                        "    <td>"+a[i].title+"</td>\n" +
                        "    <td>"+a[i].createdBy+"</td>\n" +
                        "    <td>"+a[i].typeCode+"</td>\n" +
                        "    <td>"+a[i].creationDate+"</td>\n" +
                        "    <td>"+a[i].modifyData+"</td>\n" +
                        "    <td><a href='#'>修</a>&nbsp;&nbsp; <a href='#'  onclick='delete1("+a[i].id+")'>删除</a></td>\n" +
                        "    </tr>";

                    pid = a[i].id;

                    $('#charu').append(html);
                }
            },
            error: function () {
                alert("加载失败");
                // window.location.href = "./index.html";
            }
        });


    });
    function delete1(id){
        if(confirm("确认要删除吗？"))
        $.ajax({
            "url": '/del',
            "type": "get",
            "data":{"id":id},
            "dataType": "json",
            "success": function (a) {

        if(a==true){
            window.location.reload();
            alert("删除成功");
        }

            },
            error: function () {
                alert("加载失败");
                // window.location.href = "./index.html";
            }
        });

    }
</script>

</body>
</html>